package com.lambda;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: zch
 * @Date: 2019/1/10 10:15
 * @Description:
 */
public class ConstrMethodRef {

    @FunctionalInterface
    interface UserFactory<U extends User> {
        U create(int id, String name);
    }

    static UserFactory<User> uf = User::new;

    public static void main(String[] args) throws InterruptedException {

        List<User> users = new ArrayList<User>();
        for (int i=1;i<10;i++) {

            users.add(uf.create(i, "name" + i));

        }
        users.stream().map(User::getName).forEach(System.out::println);


    }
}
